home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / p_man / cat3 / Xm / XmeGetDesktopColorCells.z / XmeGetDesktopColorCells
Text File  |  1998-10-30  |  13KB  |  265 lines

  1.  
  2.  
  3.  
  4.      XXXXmmmmeeeeGGGGeeeettttDDDDeeeesssskkkkttttooooppppCCCCoooolllloooorrrrCCCCeeeellllllllssss((((3333XXXX))))UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVVXXXXmmmmeeeeGGGGeeeettttDDDDeeeesssskkkkttttooooppppCCCCoooolllloooorrrrCCCCeeeellllllllssss((((3333XXXX))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.           XXXXmmmmeeeeGGGGeeeettttDDDDeeeesssskkkkttttooooppppCCCCoooolllloooorrrrCCCCeeeellllllllssss - return desktop pixel data in
  10.           XXXXCCCCoooolllloooorrrr[[[[]]]] format
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.           #include <Xm/ColorObjP.h>
  14.           BBBBoooooooolllleeeeaaaannnn XXXXmmmmeeeeGGGGeeeettttDDDDeeeesssskkkkttttooooppppCCCCoooolllloooorrrrCCCCeeeellllllllssss(
  15.           SSSSccccrrrreeeeeeeennnn ****ssssccccrrrreeeeeeeennnn,
  16.           CCCCoooolllloooorrrrmmmmaaaapppp ccccoooolllloooorrrrmmmmaaaapppp,
  17.           XXXXCCCCoooolllloooorrrr ****ccccoooolllloooorrrrssss,
  18.           iiiinnnntttt nnnn____ccccoooolllloooorrrrssss,
  19.           iiiinnnntttt ****nnnn____ccccoooolllloooorrrrssss____rrrreeeetttt);
  20.  
  21.      VVVVEEEERRRRSSSSIIIIOOOONNNN
  22.           This page documents Motif 2.1.
  23.  
  24.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  25.           The Motif library creates and maintains a CCCCoooolllloooorrrrOOOObbbbjjjjeeeecccctttt at
  26.           application initialization time (first _V_e_n_d_o_r_S_h_e_l_l creation)
  27.           which holds color information coming from a Color Server
  28.           running on the desktop (see Color Server protocol).  An
  29.           application that needs to use a private colormap should
  30.           include in its colormap the desktop pixels returned by the
  31.           Color Server protocol, plus the pixels used for the desktop
  32.           icons, so that the rest of the desktop doesn't go
  33.           "technicolor" when the application colormap is installed
  34.           (and the desktop default colormap is de-installed).  This
  35.           function calls XXXXmmmmeeeeGGGGeeeettttCCCCoooolllloooorrrrOOOObbbbjjjjDDDDaaaattttaaaa((((ssssccccrrrreeeeeeeennnn............)))), in order to
  36.           get the raw pixel information and fill out the XXXXCCCCoooolllloooorrrr[[[[]]]]
  37.           color array for as many pixels as specified by the ccccoooolllloooorrrrUUUUsssseeee
  38.           attributes, and then determine the RGB components for these
  39.           pixel in the desktop colormap.
  40.  
  41.           After it has retrieved the pixels of this screen's color
  42.           object using _X_m_e_G_e_t_C_o_l_o_r_O_b_j_D_a_t_a, and added the pixels to the
  43.           Color calculation cache in Motif (so that widgets created
  44.           with a colormap set to share pixels get the right pixels for
  45.           derived colors like shadows) this function calls
  46.           _X_Q_u_e_r_y_C_o_l_o_r_son the default colormap to get the RGB intensity
  47.           values for the desktop pixels in the XColor elements. It
  48.           also sets all the flags to ((((DDDDooooRRRReeeedddd||||DDDDooooGGGGrrrreeeeeeeennnn||||DDDDooooBBBBlllluuuueeee))))in the
  49.           XColor array.
  50.  
  51.           For the icon pixels, the function use _X_P_a_r_s_e_C_o_l_o_rand
  52.           _X_A_l_l_o_c_C_o_l_o_r on the default colormap using the 16 standard
  53.           desktop icon color names ( """"bbbbllllaaaacccckkkk"""",,,, """"wwwwhhhhiiiitttteeee"""",,,, """"rrrreeeedddd"""",,,, """"ggggrrrreeeeeeeennnn"""",,,,
  54.           """"bbbblllluuuueeee"""",,,, """"yyyyeeeelllllllloooowwww"""",,,, """"ccccyyyyaaaannnn"""",,,, """"mmmmaaaaggggeeeennnnttttaaaa"""",,,, """"####ddddeeeeddddeeeeddddeeeeddddeeeeddddeeeeddddeeee"""",,,,
  55.           """"####bbbbddddbbbbddddbbbbddddbbbbddddbbbbddddbbbbdddd"""",,,, """"####aaaaddddaaaaddddaaaaddddaaaaddddaaaaddddaaaadddd"""",,,, """"####999944449999444499994444999944449999444499994444"""",,,,
  56.           """"####777733337777333377773333777733337777333377773333"""",,,, """"####666633336666333366663333666633336666333366663333"""",,,, """"####444422224444222244442222444422224444222244442222"""",,,,
  57.           """"####222211112222111122221111222211112222111122221111"""") to find out the pixel ids that need to be
  58.           shared.
  59.  
  60.  
  61.  
  62.  
  63.      Page 1                                         (printed 10/24/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      XXXXmmmmeeeeGGGGeeeettttDDDDeeeesssskkkkttttooooppppCCCCoooolllloooorrrrCCCCeeeellllllllssss((((3333XXXX))))UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVVXXXXmmmmeeeeGGGGeeeettttDDDDeeeesssskkkkttttooooppppCCCCoooolllloooorrrrCCCCeeeellllllllssss((((3333XXXX))))
  71.  
  72.  
  73.  
  74.           _X_m_e_G_e_t_D_e_s_k_t_o_p_C_o_l_o_r_C_e_l_l_s returns most-interesting-pixels
  75.           first, and guarantees no duplicate pixel entries (which is
  76.           not the same as duplicate RGB entries)
  77.  
  78.           The order in the _X_C_o_l_o_r array on return is:
  79.  
  80.              +o  Foreground and background for all 8 palettes (primary,
  81.                 secondary, text, active, inactive, front-panel, ws
  82.                 buttons, in that order)
  83.  
  84.              +o  Select color for primary, secondary
  85.  
  86.              +o  The icon pixels (2 for _L_O_W__C_O_L_O_R and BBBB____WWWW, 16 for _H_I_G_H
  87.                 and _M_E_D_I_U_M__C_O_L_O_R)
  88.  
  89.              +o  TTTTooooppppsssshhhhaaaaddddoooowwww color for all 8 palettes
  90.  
  91.              +o  BBBBoooottttttttoooommmmsssshhhhaaaaddddoooowwww color for all 8 palettes (same order as
  92.                 above)
  93.  
  94.              +o  Rest of select colors
  95.  
  96.           The idea is that if an application has only, say, 12 pixels
  97.           to spare in its colormap for the desktop, it should get
  98.           shared pixels that allow most of the desktop visual to be
  99.           usable:  foreground and background colors first, mainly.
  100.  
  101.           _s_c_r_e_e_n    X screen passed in.
  102.  
  103.           _c_o_l_o_r_m_a_p  Colormap for which the pixel are fetched
  104.  
  105.           _c_o_l_o_r_s    X color structures returned (allocated by called).
  106.  
  107.           _n__c_o_l_o_r_s  Size available in colors array.
  108.  
  109.           _n__c_o_l_o_r_s__r_e_t
  110.                     Number of X colors elements filled by the function
  111.  
  112.      RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEE
  113.           False if _X_m_e_G_e_t_C_o_l_o_r_O_b_j_D_a_t_a returns False, or if ccccoooolllloooorrrrUUUUsssseeee is
  114.           _X_m_C_O__B_L_A_C_K__W_H_I_T_E.
  115.  
  116.      SSSSTTTTRRRRUUUUCCCCTTTTUUUURRRREEEESSSS
  117.           _X_C_o_l_o_r is defined in Xlib.
  118.  
  119.      EEEENNNNVVVVIIIIRRRROOOONNNNMMMMEEEENNNNTTTT
  120.           The information returned by this function depends on the
  121.           presence of an active Color Server.
  122.  
  123.      RRRREEEESSSSOOOOUUUURRRRCCCCEEEESSSS
  124.           This function is affected by the resources set on the Color
  125.           Server and useColorObj on XmScreen.
  126.  
  127.  
  128.  
  129.      Page 2                                         (printed 10/24/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      XXXXmmmmeeeeGGGGeeeettttDDDDeeeesssskkkkttttooooppppCCCCoooolllloooorrrrCCCCeeeellllllllssss((((3333XXXX))))UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVVXXXXmmmmeeeeGGGGeeeettttDDDDeeeesssskkkkttttooooppppCCCCoooolllloooorrrrCCCCeeeellllllllssss((((3333XXXX))))
  137.  
  138.  
  139.  
  140.      AAAACCCCTTTTIIIIOOOONNNNSSSS////MMMMEEEESSSSSSSSAAAAGGGGEEEESSSS
  141.           None.
  142.  
  143.      EEEERRRRRRRROOOORRRRSSSS////WWWWAAAARRRRNNNNIIIINNNNGGGGSSSS
  144.           None.
  145.  
  146.      EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  147.           After calling this function, the application can then add
  148.           more entries to the XXXXCCCCoooolllloooorrrr[[[[]]]] array (it can do that before in
  149.           fact) and call _X_S_t_o_r_e_C_o_l_o_r_s with this XXXXCCCCoooolllloooorrrr[[[[]]]] on the new
  150.           colormap (note that if a program wants to use a private
  151.           colormap and share the desktop pixels, a RRRReeeeaaaaddddWWWWrrrriiiitttteeee colormap
  152.           must be used, since pixel have to be allocated at specific
  153.           location, which is not possible with read-only cells.)
  154.  
  155.           static void
  156.           SetColormap(Widget widget,
  157.                       int pixel_for_desktop)
  158.           {
  159.               Colormap my_colormap;
  160.               int ncolors_ret, i, p;
  161.               XColor    colors[256];
  162.  
  163.               if (!XtIsRealized(widget)) return;
  164.  
  165.               /* create a readwrite colormap */
  166.               my_colormap = XCreateColormap(XtDisplay(widget),
  167.                                             XtWindow(widget),
  168.                                             XDefaultVisual(XtDisplay(widget), 0),
  169.                                             AllocAll);
  170.  
  171.               /* we need to keep track of which pixel are used, mark
  172.                  them all free before calling XmeGet... */
  173.               for(i=0; i<256; i++) colors[i].pixel = -1;
  174.  
  175.               /* get the desktop pixels in the array */
  176.               XmeGetDesktopColorCells (XtScreen(widget), my_colormap,
  177.                                        colors, pixel_for_desktop,
  178.                                        &ncolors_ret);
  179.  
  180.               /* then fill in the rest of our private colormap */
  181.               for(i=ncolors_ret, p = 0; i<256; i++) {
  182.                           /* get a free pixel id */
  183.                           while (p <= 255 && colors[p].pixel != -1) p ++;
  184.                           colors[i].pixel = p;
  185.                           color[i].flags = DoRed|DoGreen|DoBlue;
  186.                   color[i].red = color[i].green = color[i].blue = i * 256;
  187.               }
  188.  
  189.               XStoreColors(XtDisplay(widget), my_colormap, colors, 256);
  190.               XtVaSetValues(widget, XmNcolormap, my_colormap, NULL);
  191.           }
  192.  
  193.  
  194.  
  195.      Page 3                                         (printed 10/24/98)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      XXXXmmmmeeeeGGGGeeeettttDDDDeeeesssskkkkttttooooppppCCCCoooolllloooorrrrCCCCeeeellllllllssss((((3333XXXX))))UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVVXXXXmmmmeeeeGGGGeeeettttDDDDeeeesssskkkkttttooooppppCCCCoooolllloooorrrrCCCCeeeellllllllssss((((3333XXXX))))
  203.  
  204.  
  205.  
  206.           main () {
  207.               toplevel = XtAppInitialize(...);
  208.               XtRealizeWidget(toplevel);
  209.  
  210.               SetColormap (toplevel, 40);
  211.               ...
  212.           }
  213.  
  214.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  215.           , , XXXXmmmmeeeeGGGGeeeettttCCCCoooolllloooorrrrOOOObbbbjjjjDDDDaaaattttaaaa(3)
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.      Page 4                                         (printed 10/24/98)
  262.  
  263.  
  264.  
  265.